package com.edu.study.base.StuAnswerResultDetail.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.StuAnswerResultDetail.domain.StuAnswerResultDetail;
import com.edu.study.base.StuAnswerResultDetail.service.IStuAnswerResultDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生答题结果明细Controller
 * 
 * @author jjt
 * @date 2021-06-20
 */
@RestController
@RequestMapping("/study/stuAnswerResultDetail")
public class StuAnswerResultDetailController extends BaseController
{
    @Autowired
    private IStuAnswerResultDetailService stuAnswerResultDetailService;

    /**
     * 查询学生答题结果明细列表
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuAnswerResultDetail stuAnswerResultDetail)
    {
        startPage();
        List<StuAnswerResultDetail> list = stuAnswerResultDetailService.selectStuAnswerResultDetailList(stuAnswerResultDetail);
        return getDataTable(list);
    }

    /**
     * 导出学生答题结果明细列表
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultDetail:export')")
    @Log(title = "学生答题结果明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StuAnswerResultDetail stuAnswerResultDetail)
    {
        List<StuAnswerResultDetail> list = stuAnswerResultDetailService.selectStuAnswerResultDetailList(stuAnswerResultDetail);
        ExcelUtil<StuAnswerResultDetail> util = new ExcelUtil<StuAnswerResultDetail>(StuAnswerResultDetail.class);
        return util.exportExcel(list, "stuAnswerResultDetail");
    }

    /**
     * 获取学生答题结果明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(stuAnswerResultDetailService.selectStuAnswerResultDetailById(id));
    }

    /**
     * 新增学生答题结果明细
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultDetail:add')")
    @Log(title = "学生答题结果明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuAnswerResultDetail stuAnswerResultDetail)
    {
        return toAjax(stuAnswerResultDetailService.insertStuAnswerResultDetail(stuAnswerResultDetail));
    }

    /**
     * 修改学生答题结果明细
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultDetail:edit')")
    @Log(title = "学生答题结果明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuAnswerResultDetail stuAnswerResultDetail)
    {
        return toAjax(stuAnswerResultDetailService.updateStuAnswerResultDetail(stuAnswerResultDetail));
    }

    /**
     * 删除学生答题结果明细
     */
    @PreAuthorize("@ss.hasPermi('study:stuAnswerResultDetail:remove')")
    @Log(title = "学生答题结果明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stuAnswerResultDetailService.deleteStuAnswerResultDetailByIds(ids));
    }
}
